#include "KDMHitsCollection.hh"
#include "KDMHit.hh"
#include "KDMGlobals.hh"

KDMHitsCollection::KDMHitsCollection(G4String detName,G4String colName):G4VHitsCollection(detName,colName)
{
	size = 0;
	collection = new KDMHit*[0];
}

KDMHitsCollection::~KDMHitsCollection()
{
	for(size_t l = 0;l < size;l++) delete collection[l];
	delete collection;
}

G4VHit* KDMHitsCollection::GetHit(size_t index) const
{
	return collection[index];
}

size_t KDMHitsCollection::GetSize() const
{
	return size;
}

void KDMHitsCollection::Insert(KDMHit* newHit)
{
	KDMHit** collectionOld = collection;

	collection = new KDMHit*[size+1];
	
	for(size_t l = 0;l < size;l++) collection[l] = collectionOld[l];
	delete collectionOld;

	size++;

	collection[size-1] = newHit;
}
